using System;
using System.Collections.Generic;
using System.Text;
using AllegNet;

namespace DemonHunter
{
    class UI
    {
        private static UI me;
        
        private Game game;

        private Bmp UIBmp;
        private Bmp UIBorder;

        public UI()
        {
            me = this;
            game = Game.GetInstance();

            UIBmp = game.CreateBitmap(1024, 128);
            UIBorder = game.LoadBitmap("c:\\DemonHunterart\\uiborder.bmp");
            game.Blit(UIBorder, UIBmp, 0, 0, 0, 0, 128, 128);
            game.Blit(UIBorder, UIBmp, 0, 0, 1024 - 128, 0, 128, 128);

            game.RectFill(UIBmp, 0, 0, 1024, 2, 40000);
        }

        public void Refresh()
        {
            PlayerCharacter player = PlayerCharacter.GetInstance();

            game.RectFill(UIBmp, 129, 3, 1024 - 129, 128, 0);

            game.TextOutEx(UIBmp, game.DefaultFont, "Health: " + player.GetHealth(), 200, 50, System.Drawing.Color.Aquamarine, System.Drawing.Color.Black);
            game.TextOutEx(UIBmp, game.DefaultFont, "Ammo: " + player.GetAmmo(), 500, 50, System.Drawing.Color.Aquamarine, System.Drawing.Color.Black);
            game.TextOutEx(UIBmp, game.DefaultFont, "Grenades: " + player.GetGrenades(), 1024 - 250, 50, System.Drawing.Color.Aquamarine, System.Drawing.Color.Black);

            game.TextOutEx(UIBmp, game.DefaultFont, "FPS: " + game.GetFPS().ToString(), 1024 - 250, 100, System.Drawing.Color.Aquamarine, System.Drawing.Color.Black);

            if (player.GetHealth() <= 0) game.TextOutEx(UIBmp, game.DefaultFont, "Game Over", 500, 10, System.Drawing.Color.Aquamarine, System.Drawing.Color.Black);
        }

        public Bmp GetBitmap() { return UIBmp; }

        public static UI GetInstance() { return me; }
    }
}
